<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@include file="../../common/operation_forbid.jsp" %>
<%@include file="../../common/jsVersion.jsp"%>
<c:set var="contextPath" value="${pageContext.request.contextPath}"/>
<script type="text/javascript">
    var contextPath = '${contextPath}';
    var documentType=${documentType};
    var customerId = '${customerId}';
    var roomId = '${roomId}';
    var closeTabRoomId = roomId;
    var menu = '${menu}';
    var returnUrl = '${returnUrl}';
    var customerProjectId="${customerProjectId}";
    var showChooseCustomer=${showChooseCustomer};
</script>
<!DOCTYPE html >
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>认筹</title>
    <!-- neptune -->
    <%@include file="../../common/extInclude.jsp" %>
    <script type="text/javascript" src="${contextPath}/static/js/components/customerComponent.js?v=${jsVersion}"></script>
    <script type="text/javascript" src="${contextPath}/static/js/components/estateComponent.js?v=${jsVersion}"></script>
    <script type="text/javascript" src="${contextPath}/static/js/customer/payDeposit/add.js?v=${jsVersion}"></script>
    <script type="text/javascript" src="${contextPath}/static/js/components/fileComponent.js?v=${jsVersion}"></script>
</head>
<script type="text/javascript">
var idata = ${permitBtn}; 
//认筹按钮权限
var payDepositAddOK=true;
if(Ext.Array.contains(idata,"marketing:payDeposit:add")){
	payDepositAddOK=false;
}
var userIdStore = null;
Ext.onReady(function() {
    userIdStore = new Ext.data.Store({
    	        fields: ["userName", "id"],
    	        proxy:{
    	            type:'ajax',
    	            url:contextPath+'/customer/customer/userByProjectIdForGroup',
    	            reader:{
                        type: 'json', 
                        root: 'root'  //数据
                   }
    	        }
    });
	Ext.tip.QuickTipManager.init()
	var addPanel=Ext.create("customer.payDeposit.addPanel");
	
	if(roomId!="" && null!=roomId){
		//初始化房间信息
	 	 Ext.Ajax.request({
     	    url: contextPath+'/estate/projectRoom/roomDetail',
     	    params: {
     	    	id: roomId
     	    },
     	    method: 'POST',
     	    success: function(response){
     	        var text = Ext.decode(response.responseText);
     	        if(text.res=="1"){
     	        	 console.log(text.obj);
     	        	 //var result=Ext.JSON.decode(text.obj);
     	        	 
     	        	addPanel.getComponent("estatePanel").getForm().setValues(text.obj);
     	        }
     	    }
     	});
	}
	if(customerId!="" && null!=customerId){
		//初始化房间信息
	 	 Ext.Ajax.request({
    	    url: contextPath+'/customer/customer/customerDetail',
    	    params: {
    	    	id: customerId
    	    },
    	    method: 'POST',
    	    success: function(response){
    	        var text = Ext.decode(response.responseText);
    	        if(text.res=="1"){
    	        	 //初始化客户信息
    	     		  addPanel.getComponent("customerPanel").getForm().setValues(text.obj);
    	     		  var familyMemberGridStore=addPanel.getComponent("customerPanel").getComponent("familyMemberGridPanel").getStore();
    	     		  var extraParams=familyMemberGridStore.getProxy().extraParams;
 		 	          extraParams.customerId=customerId;
 		 	          familyMemberGridStore.load();
   		 	         Ext.getCmp('userName').setValue(text.obj.userId);
   		 	         userIdStore.load({
  		 	        	  params:{
   		 	        		  'projectId':text.obj.projectId
   		 	        	  }
   		 	         });
    	        }
    	    }
    	});
		
	}
});
</script>

<body>
</body>
</html>